﻿Imports System
Imports System.Collections
Imports System.Collections.Generic
Imports System.Collections.ObjectModel
Imports System.Collections.Specialized
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.ComponentModel.Design.Serialization
Imports System.Drawing
Imports System.Drawing.Design
Imports System.Drawing.Drawing2D
Imports System.Drawing.Imaging
Imports System.Globalization
Imports System.IO
Imports System.Reflection
Imports System.Windows.Forms
Imports System.Windows.Forms.Design
Imports System.Workflow.ComponentModel
Imports System.Workflow.ComponentModel.Compiler
Imports System.Workflow.ComponentModel.Serialization

Namespace System.Workflow.ComponentModel.Design
    <DesignerSerializer(GetType(ActivityDesignerLayoutSerializer), GetType(WorkflowMarkupSerializer)), ActivityDesignerTheme(GetType(ActivityDesignerTheme)), ToolboxItemFilter("Microsoft.Workflow.VSDesigner", ToolboxItemFilterType.Require), ToolboxItemFilter("System.Workflow.ComponentModel.Design.ActivitySet", ToolboxItemFilterType.Custom), SRCategory("ActivityDesigners", "System.Workflow.ComponentModel.Design.DesignerResources")> _
    Public Class ActivityDesigner
        Implements IDesignerFilter, IToolboxUser, IPersistUIState, IWorkflowDesignerMessageSink, IWorkflowRootDesigner, IRootDesigner, IDesigner, IDisposable, IConnectableDesigner
        ' Methods
        Public Overridable Function CanBeParentedTo(ByVal parentActivityDesigner As CompositeActivityDesigner) As Boolean
            If (parentActivityDesigner Is Nothing) Then
                Throw New ArgumentNullException("parentActivityDesigner")
            End If
            Return True
        End Function

        Protected Overridable Function CanConnect(ByVal source As ConnectionPoint, ByVal target As ConnectionPoint) As Boolean
            Return True
        End Function

        Friend Shared Function CreateDesigner(ByVal serviceProvider As IServiceProvider, ByVal activity As Activity) As ActivityDesigner
            Dim designer As IDesigner = Nothing
            Dim type As Type = ActivityDesigner.GetDesignerType(serviceProvider, activity.GetType, GetType(IDesigner))
            If (type Is Nothing) Then
                type = ActivityDesigner.GetDesignerType(serviceProvider, activity.GetType, Nothing)
            End If
            If (Not type Is Nothing) Then
                Try 
                    designer = [TryCast](Activator.CreateInstance(type, (BindingFlags.CreateInstance Or (BindingFlags.NonPublic Or (BindingFlags.Public Or BindingFlags.Instance))), Nothing, Nothing, Nothing),IDesigner)
                    designer.Initialize(activity)
                Catch obj1 As Object
                End Try
            End If
            Return [TryCast](designer,ActivityDesigner)
        End Function

        Friend Shared Function CreateTransientDesigner(ByVal activity As Activity) As ActivityDesigner
            Dim designer As New ActivityDesigner
            Dim designerTheme As ActivityDesignerTheme = designer.DesignerTheme
            [Using] bitmap As Bitmap = New Bitmap(designerTheme.Size.Width, designerTheme.Size.Height, PixelFormat.Format32bppArgb)
                [Using] graphics As Graphics = Graphics.FromImage(bitmap)
                    designer.Image = ActivityToolboxItem.GetToolboxImage(activity.GetType)
                    designer.Location = New Point(-1, -1)
                    designer.Location = Point.Empty
                    designer.Size = designer.OnLayoutSize(New ActivityDesignerLayoutEventArgs(graphics, designer.DesignerTheme))
                End [Using]
            End [Using]
            Return designer
        End Function

        Protected Overridable Function CreateView(ByVal viewTechnology As ViewTechnology) As WorkflowView
            Return New WorkflowView(Me.Activity.Site) { _
                .ShowToolContainer = True _
            }
        End Function

        Public Sub Dispose()
            Me.Dispose(True)
            GC.SuppressFinalize(Me)
        End Sub

        Protected Overridable Sub Dispose(ByVal disposing As Boolean)
            If (disposing AndAlso Me.IsRootDesigner) Then
                If (Not Me.workflowView Is Nothing) Then
                    Me.workflowView.Dispose
                    Me.workflowView = Nothing
                End If
                Dim host As IDesignerHost = [TryCast](Me.GetService(GetType(IDesignerHost)),IDesignerHost)
                If (((Not host Is Nothing) AndAlso (Me.InvokingDesigner Is Nothing)) AndAlso (Me.Activity Is host.RootComponent)) Then
                    RemoveHandler host.LoadComplete, New EventHandler(AddressOf Me.OnLoadComplete)
                End If
                Dim service As IComponentChangeService = [TryCast](Me.GetService(GetType(IComponentChangeService)),IComponentChangeService)
                If (Not service Is Nothing) Then
                    RemoveHandler service.ComponentChanged, New ComponentChangedEventHandler(AddressOf Me.OnComponentChanged)
                    RemoveHandler service.ComponentRename, New ComponentRenameEventHandler(AddressOf Me.OnComponentRenamed)
                End If
            End If
        End Sub

        Protected Overridable Sub DoDefaultAction()
            If Not Me.IsLocked Then
                Dim attribute As DefaultEventAttribute = [TryCast](TypeDescriptor.GetAttributes(Me.Activity).Item(GetType(DefaultEventAttribute)),DefaultEventAttribute)
                If (((Not attribute Is Nothing) AndAlso (Not attribute.Name Is Nothing)) AndAlso (attribute.Name.Length <> 0)) Then
                    Dim descriptor As ActivityBindPropertyDescriptor = [TryCast](TypeDescriptor.GetProperties(Me.Activity).Item(attribute.Name),ActivityBindPropertyDescriptor)
                    If ((Not descriptor Is Nothing) AndAlso Not TypeOf descriptor.GetValue(Me.Activity) Is ActivityBind) Then
                        Dim service As IEventBindingService = DirectCast(Me.GetService(GetType(IEventBindingService)), IEventBindingService)
                        If (Not service Is Nothing) Then
                            Dim e As EventDescriptor = service.GetEvent(descriptor.RealPropertyDescriptor)
                            If (Not e Is Nothing) Then
                                Dim str As String = [TryCast](descriptor.RealPropertyDescriptor.GetValue(Me.Activity),String)
                                If String.IsNullOrEmpty(str) Then
                                    str = DesignerHelpers.CreateUniqueMethodName(Me.Activity, e.Name, e.EventType)
                                End If
                                descriptor.SetValue(Me.Activity, str)
                                service.ShowCode(Me.Activity, e)
                            End If
                        End If
                    End If
                End If
            End If
        End Sub

        Public Sub EnsureVisible()
            Dim parentView As WorkflowView = Me.ParentView
            If (Not parentView Is Nothing) Then
                parentView.EnsureVisible(Me.Activity)
            End If
        End Sub

        Protected Overrides Sub Finalize()
            Try 
                Me.Dispose(False)
            Finally
                MyBase.Finalize
            End Try
        End Sub

        Friend Shared Function GetActivityDescription(ByVal activityType As Type) As String
            If (activityType Is Nothing) Then
                Return Nothing
            End If
            Dim customAttributes As Object() = activityType.GetCustomAttributes(GetType(DescriptionAttribute), False)
            If ((Not customAttributes Is Nothing) AndAlso (customAttributes.GetLength(0) = 0)) Then
                customAttributes = activityType.GetCustomAttributes(GetType(DescriptionAttribute), True)
            End If
            Dim attribute As DescriptionAttribute = If(((Not customAttributes Is Nothing) AndAlso (customAttributes.GetLength(0) > 0)), [TryCast](customAttributes(0),DescriptionAttribute), Nothing)
            If (attribute Is Nothing) Then
                Return String.Empty
            End If
            Return attribute.Description
        End Function

        Public Overridable Function GetConnectionPoints(ByVal edges As DesignerEdges) As ReadOnlyCollection([Of] ConnectionPoint)
            Dim list As New List([Of] ConnectionPoint)
            If ((edges And DesignerEdges.Left) > DesignerEdges.None) Then
                Dim i As Integer
                For i = 0 To Me.GetConnections(DesignerEdges.Left).Count - 1
                    list.Add(New ConnectionPoint(Me, DesignerEdges.Left, i))
                Next i
            End If
            If ((edges And DesignerEdges.Right) > DesignerEdges.None) Then
                Dim j As Integer
                For j = 0 To Me.GetConnections(DesignerEdges.Right).Count - 1
                    list.Add(New ConnectionPoint(Me, DesignerEdges.Right, j))
                Next j
            End If
            If ((edges And DesignerEdges.Top) > DesignerEdges.None) Then
                Dim k As Integer
                For k = 0 To Me.GetConnections(DesignerEdges.Top).Count - 1
                    list.Add(New ConnectionPoint(Me, DesignerEdges.Top, k))
                Next k
            End If
            If ((edges And DesignerEdges.Bottom) > DesignerEdges.None) Then
                Dim m As Integer
                For m = 0 To Me.GetConnections(DesignerEdges.Bottom).Count - 1
                    list.Add(New ConnectionPoint(Me, DesignerEdges.Bottom, m))
                Next m
            End If
            Return list.AsReadOnly
        End Function

        Protected Friend Overridable Function GetConnections(ByVal edges As DesignerEdges) As ReadOnlyCollection([Of] Point)
            Dim bounds As Rectangle = Me.Bounds
            Dim list As New List([Of] Point)
            If ((edges And DesignerEdges.Left) > DesignerEdges.None) Then
                list.Add(New Point(bounds.Left, (bounds.Top + (bounds.Height / 2))))
            End If
            If ((edges And DesignerEdges.Top) > DesignerEdges.None) Then
                list.Add(New Point((bounds.Left + (bounds.Width / 2)), bounds.Top))
            End If
            If ((edges And DesignerEdges.Right) > DesignerEdges.None) Then
                list.Add(New Point(bounds.Right, (bounds.Top + (bounds.Height / 2))))
            End If
            If ((edges And DesignerEdges.Bottom) > DesignerEdges.None) Then
                list.Add(New Point((bounds.Left + (bounds.Width / 2)), bounds.Bottom))
            End If
            Return list.AsReadOnly
        End Function

        Friend Shared Function GetDesigner(ByVal activity As Activity) As ActivityDesigner
            Dim designer As ActivityDesigner = Nothing
            If ((Not activity Is Nothing) AndAlso (Not activity.Site Is Nothing)) Then
                Dim service As IDesignerHost = [TryCast](activity.Site.GetService(GetType(IDesignerHost)),IDesignerHost)
                If (Not service Is Nothing) Then
                    designer = [TryCast](service.GetDesigner(activity),ActivityDesigner)
                End If
            End If
            Return designer
        End Function

        Friend Shared Function GetDesignerType(ByVal serviceProvider As IServiceProvider, ByVal activityType As Type, ByVal designerBaseType As Type) As Type
            Dim type As Type = Nothing
            Dim attribute As Attribute
            For Each attribute In TypeDescriptor.GetAttributes(activityType)
                Dim attribute2 As DesignerAttribute = [TryCast](attribute,DesignerAttribute)
                If ((Not attribute2 Is Nothing) AndAlso ((designerBaseType Is Nothing) OrElse (attribute2.DesignerBaseTypeName = designerBaseType.AssemblyQualifiedName))) Then
                    Dim index As Integer = attribute2.DesignerTypeName.IndexOf(","c)
                    Dim name As String = If((index >= 0), attribute2.DesignerTypeName.Substring(0, index), attribute2.DesignerTypeName)
                    type = activityType.Assembly.GetType(name)
                    If ((type Is Nothing) AndAlso (Not serviceProvider Is Nothing)) Then
                        Dim service As ITypeResolutionService = [TryCast](serviceProvider.GetService(GetType(ITypeResolutionService)),ITypeResolutionService)
                        type = If((Not service Is Nothing), service.GetType(attribute2.DesignerTypeName), Nothing)
                    End If
                    If (type Is Nothing) Then
                        type = Type.GetType(attribute2.DesignerTypeName)
                    End If
                    Return type
                End If
            Next
            Return type
        End Function

        Friend Shared Function GetParentDesigner(ByVal obj As Object) As CompositeActivityDesigner
            Dim parentDesigner As CompositeActivityDesigner = Nothing
            If TypeOf obj Is HitTestInfo Then
                Return [TryCast](DirectCast(obj, HitTestInfo).AssociatedDesigner,CompositeActivityDesigner)
            End If
            If TypeOf obj Is Activity Then
                Dim designer2 As ActivityDesigner = ActivityDesigner.GetDesigner([TryCast](obj,Activity))
                If (Not designer2 Is Nothing) Then
                    parentDesigner = designer2.ParentDesigner
                End If
            End If
            Return parentDesigner
        End Function

        Public Function GetPreviewImage(ByVal compatibleGraphics As Graphics) As Image
            If (compatibleGraphics Is Nothing) Then
                Throw New ArgumentNullException("compatibleGraphics")
            End If
            If (Me.Activity.Site Is Nothing) Then
                DirectCast(Me, IWorkflowDesignerMessageSink).OnLayoutSize(compatibleGraphics)
                DirectCast(Me, IWorkflowDesignerMessageSink).OnLayoutPosition(compatibleGraphics)
            End If
            Dim ambientTheme As AmbientTheme = WorkflowTheme.CurrentTheme.AmbientTheme
            Dim image As New Bitmap((Me.Size.Width + (4 * ambientTheme.Margin.Width)), (Me.Size.Height + (4 * ambientTheme.Margin.Height)), PixelFormat.Format32bppArgb)
            Dim manager As GlyphManager = If(((Not Me.Activity Is Nothing) AndAlso (Not Me.Activity.Site Is Nothing)), [TryCast](Me.GetService(GetType(IDesignerGlyphProviderService)),GlyphManager), Nothing)
            [Using] graphics As Graphics = Graphics.FromImage(image)
                [Using] brush As Brush = New SolidBrush(Color.FromArgb(0, &HFF, 0, &HFF))
                    graphics.FillRectangle(brush, 0, 0, image.Width, image.Height)
                    graphics.TranslateTransform(CSng((-Me.Location.X + (2 * ambientTheme.Margin.Width))), CSng((-Me.Location.Y + (2 * ambientTheme.Margin.Height))))
                    Dim bounds As Rectangle = Me.Bounds
                    Dim viewPort As New Rectangle(bounds.Location, New Size((bounds.Width + 1), (bounds.Height + 1)))
                    Dim queue As New Queue([Of] ActivityDesigner)
                    queue.Enqueue(Me)
                    Do While (queue.Count > 0)
                        Dim designer As ActivityDesigner = queue.Dequeue
                        designer.OnPaint(New ActivityDesignerPaintEventArgs(graphics, designer.Bounds, viewPort, designer.DesignerTheme))
                        Dim glyphs As ActivityDesignerGlyphCollection = If((Not manager Is Nothing), manager.GetDesignerGlyphs(designer), Me.Glyphs)
                        Dim glyph As DesignerGlyph
                        For Each glyph In glyphs
                            If Not TypeOf glyph Is SelectionGlyph Then
                                glyph.Draw(graphics, designer)
                            End If
                        Next
                        Dim designer2 As CompositeActivityDesigner = [TryCast](designer,CompositeActivityDesigner)
                        If (Not designer2 Is Nothing) Then
                            Dim designer3 As ActivityDesigner
                            For Each designer3 In designer2.ContainedDesigners
                                If (((Not designer3 Is Nothing) AndAlso designer2.Expanded) AndAlso designer2.IsContainedDesignerVisible(designer3)) Then
                                    queue.Enqueue(designer3)
                                End If
                            Next
                        End If
                    Loop
                End [Using]
            End [Using]
            Return image
        End Function

        Public Shared Function GetRootDesigner(ByVal serviceProvider As IServiceProvider) As ActivityDesigner
            If (serviceProvider Is Nothing) Then
                Throw New ArgumentNullException("serviceProvider")
            End If
            Dim service As IDesignerHost = [TryCast](serviceProvider.GetService(GetType(IDesignerHost)),IDesignerHost)
            If (service Is Nothing) Then
                Return Nothing
            End If
            Return ActivityDesigner.GetDesigner([TryCast](service.RootComponent,Activity))
        End Function

        Friend Shared Function GetSafeRootDesigner(ByVal serviceProvider As IServiceProvider) As ActivityDesigner
            If (serviceProvider Is Nothing) Then
                Return Nothing
            End If
            Return ActivityDesigner.GetRootDesigner(serviceProvider)
        End Function

        Protected Function GetService(ByVal serviceType As Type) As Object
            If (serviceType Is Nothing) Then
                Throw New ArgumentNullException("serviceType")
            End If
            If ((Not Me.activity Is Nothing) AndAlso (Not Me.activity.Site Is Nothing)) Then
                Return Me.activity.Site.GetService(serviceType)
            End If
            Return Nothing
        End Function

        Private Function GetVisible() As Boolean
            Dim activity As Activity = Me.Activity
            If (Not activity Is Nothing) Then
                Do While (Not activity Is Nothing)
                    Dim containedDesigner As ActivityDesigner = ActivityDesigner.GetDesigner(activity)
                    If (Not containedDesigner Is Nothing) Then
                        Dim parentDesigner As CompositeActivityDesigner = containedDesigner.ParentDesigner
                        If ((parentDesigner Is Nothing) AndAlso (Not containedDesigner Is Nothing)) Then
                            Return True
                        End If
                        If (((parentDesigner Is Nothing) OrElse Not parentDesigner.Expanded) OrElse Not parentDesigner.IsContainedDesignerVisible(containedDesigner)) Then
                            Return False
                        End If
                        activity = parentDesigner.Activity
                    Else
                        activity = Nothing
                    End If
                Loop
                Return True
            End If
            Return False
        End Function

        Public Overridable Function HitTest(ByVal point As Point) As HitTestInfo
            Dim nowhere As HitTestInfo = HitTestInfo.Nowhere
            If (TypeOf Me.ParentDesigner Is FreeformActivityDesigner OrElse ((Me.ParentDesigner Is Nothing) AndAlso TypeOf Me Is FreeformActivityDesigner)) Then
                Dim connectionPoints As ReadOnlyCollection([Of] ConnectionPoint) = Me.GetConnectionPoints(DesignerEdges.All)
                Dim i As Integer
                For i = 0 To connectionPoints.Count - 1
                    If connectionPoints.Item(i).Bounds.Contains(point) Then
                        nowhere = New ConnectionPointHitTestInfo(connectionPoints.Item(i))
                        Exit For
                    End If
                Next i
            End If
            Dim bounds As Rectangle = Me.Bounds
            If (bounds.Contains(point) AndAlso (nowhere Is HitTestInfo.Nowhere)) Then
                Dim location As HitTestLocations = If(bounds.Contains(point), HitTestLocations.Designer, HitTestLocations.None)
                Dim rectangle2 As New Rectangle(bounds.Left, bounds.Top, (bounds.Left - bounds.Left), bounds.Height)
                location = (location Or If(rectangle2.Contains(point), HitTestLocations.Left, location))
                rectangle2 = New Rectangle(bounds.Left, bounds.Top, bounds.Width, (bounds.Height - bounds.Height))
                location = (location Or If(rectangle2.Contains(point), HitTestLocations.Top, location))
                rectangle2 = New Rectangle(bounds.Right, bounds.Top, (bounds.Width - bounds.Width), bounds.Height)
                location = (location Or If(rectangle2.Contains(point), HitTestLocations.Right, location))
                rectangle2 = New Rectangle(bounds.Left, bounds.Bottom, bounds.Width, (bounds.Bottom - bounds.Bottom))
                location = (location Or If(rectangle2.Contains(point), HitTestLocations.Bottom, location))
                nowhere = New HitTestInfo(Me, location)
            End If
            Return nowhere
        End Function

        Protected Overridable Sub Initialize(ByVal activity As Activity)
            If (activity Is Nothing) Then
                Throw New ArgumentNullException("activity")
            End If
            If Me.IsRootDesigner Then
                Dim host As IDesignerHost = DirectCast(Me.GetService(GetType(IDesignerHost)), IDesignerHost)
                If ((Not host Is Nothing) AndAlso (Me.InvokingDesigner Is Nothing)) Then
                    AddHandler host.LoadComplete, New EventHandler(AddressOf Me.OnLoadComplete)
                End If
                Dim service As IComponentChangeService = [TryCast](Me.GetService(GetType(IComponentChangeService)),IComponentChangeService)
                If (Not service Is Nothing) Then
                    AddHandler service.ComponentChanged, New ComponentChangedEventHandler(AddressOf Me.OnComponentChanged)
                    AddHandler service.ComponentRename, New ComponentRenameEventHandler(AddressOf Me.OnComponentRenamed)
                End If
            End If
            Me.Text = If(Not String.IsNullOrEmpty(activity.Name), activity.Name, activity.GetType.Name)
            Me.Image = Me.StockImage
            Me.RefreshDesignerVerbs
            If Me.IsLocked Then
                DesignerHelpers.MakePropertiesReadOnly(activity.Site, activity)
            End If
        End Sub

        Friend Function InternalRectangleToScreen(ByVal rectangle As Rectangle) As Rectangle
            Return Me.RectangleToScreen(rectangle)
        End Function

        Public Sub Invalidate()
            Dim parentView As WorkflowView = Me.ParentView
            If (Not parentView Is Nothing) Then
                parentView.InvalidateLogicalRectangle(Me.Bounds)
                Dim service As GlyphManager = [TryCast](Me.GetService(GetType(IDesignerGlyphProviderService)),GlyphManager)
                If (Not service Is Nothing) Then
                    Dim glyph As DesignerGlyph
                    For Each glyph In service.GetDesignerGlyphs(Me)
                        parentView.InvalidateLogicalRectangle(glyph.GetBounds(Me, False))
                    Next
                End If
            End If
        End Sub

        Public Sub Invalidate(ByVal rectangle As Rectangle)
            Dim parentView As WorkflowView = Me.ParentView
            If (Not parentView Is Nothing) Then
                rectangle = Rectangle.Intersect(Me.Bounds, rectangle)
                parentView.InvalidateLogicalRectangle(rectangle)
            End If
        End Sub

        Public Shared Function IsCommentedActivity(ByVal activity As Activity) As Boolean
            If (activity Is Nothing) Then
                Throw New ArgumentNullException("activity")
            End If
            Dim flag As Boolean = False
            Dim activity2 As CompositeActivity = activity.Parent
            Do While ((Not activity2 Is Nothing) AndAlso Not flag)
                flag = ((Not activity2 Is Nothing) AndAlso Not activity2.Enabled)
                activity2 = activity2.Parent
            Loop
            Return flag
        End Function

        Protected Overridable Function IsSupportedActivityType(ByVal activityType As Type) As Boolean
            Return True
        End Function

        Protected Overridable Sub LoadViewState(ByVal reader As BinaryReader)
            If (reader Is Nothing) Then
                Throw New ArgumentNullException("reader")
            End If
        End Sub

        Protected Overridable Sub OnActivityChanged(ByVal e As ActivityChangedEventArgs)
            If (e Is Nothing) Then
                Throw New ArgumentNullException("e")
            End If
            If (((Not e.Member Is Nothing) AndAlso (Not e.Member.Name Is Nothing)) AndAlso e.Member.Name.Equals("Name")) Then
                Me.Text = Me.Activity.Name
            End If
            If Not TypeOf e.OldValue Is ActivityCollectionChangeEventArgs Then
                Me.RefreshDesignerVerbs
            End If
            Dim service As IUIService = [TryCast](Me.GetService(GetType(IUIService)),IUIService)
            If (Not service Is Nothing) Then
                service.SetUIDirty
            End If
            Me.rulesText = Nothing
        End Sub

        Protected Overridable Sub OnBeginResizing(ByVal e As ActivityDesignerResizeEventArgs)
        End Sub

        Private Sub OnBindProperty(ByVal sender As Object, ByVal e As EventArgs)
            Dim service As IExtendedUIService = [TryCast](Me.GetService(GetType(IExtendedUIService)),IExtendedUIService)
            If (Not service Is Nothing) Then
                BindUITypeEditor.EditValue(service.GetSelectedPropertyContext)
            End If
        End Sub

        Private Sub OnBindPropertyStatusUpdate(ByVal sender As Object, ByVal e As EventArgs)
            Dim verb As DesignerVerb = [TryCast](sender,DesignerVerb)
            If (Not verb Is Nothing) Then
                Dim flag As Boolean = False
                Dim str As String = Nothing
                Dim service As IExtendedUIService = [TryCast](Me.GetService(GetType(IExtendedUIService)),IExtendedUIService)
                If (Not service Is Nothing) Then
                    Dim selectedPropertyContext As ITypeDescriptorContext = service.GetSelectedPropertyContext
                    flag = (((Not selectedPropertyContext Is Nothing) AndAlso ActivityBindPropertyDescriptor.IsBindableProperty(selectedPropertyContext.PropertyDescriptor)) AndAlso Not selectedPropertyContext.PropertyDescriptor.IsReadOnly)
                    str = If((Not selectedPropertyContext Is Nothing), selectedPropertyContext.PropertyDescriptor.Name, Nothing)
                End If
                verb.Properties.Item("Text") = If(((Not str Is Nothing) AndAlso verb.Enabled), String.Format(CultureInfo.CurrentCulture, DR.GetString("BindSelectedPropertyFormat", New Object(0  - 1) {}), New Object() { str }), DR.GetString("BindSelectedProperty", New Object(0  - 1) {}))
                verb.Enabled = (flag AndAlso Not Me.IsLocked)
            End If
        End Sub

        Private Sub OnComponentChanged(ByVal sender As Object, ByVal e As ComponentChangedEventArgs)
            If ((((Not e.Component Is Nothing) AndAlso TypeOf e.OldValue Is ActivityBind) AndAlso Not TypeOf e.NewValue Is ActivityBind) OrElse (Not TypeOf e.OldValue Is ActivityBind AndAlso TypeOf e.NewValue Is ActivityBind)) Then
                TypeDescriptor.Refresh(e.Component)
            End If
            Dim service As IReferenceService = [TryCast](Me.GetService(GetType(IReferenceService)),IReferenceService)
            Dim activity As Activity = If((Not service Is Nothing), [TryCast](service.GetComponent(e.Component),Activity), [TryCast](e.Component,Activity))
            If (Not activity Is Nothing) Then
                Dim designer As ActivityDesigner = ActivityDesigner.GetDesigner(activity)
                If (Not designer Is Nothing) Then
                    designer.OnActivityChanged(New ActivityChangedEventArgs(activity, e.Member, e.OldValue, e.NewValue))
                End If
            End If
        End Sub

        Private Sub OnComponentRenamed(ByVal sender As Object, ByVal e As ComponentRenameEventArgs)
            If (Not ActivityDesigner.GetDesigner([TryCast](e.Component,Activity)) Is Nothing) Then
                Me.Text = Me.Activity.Name
            End If
        End Sub

        Protected Overridable Sub OnConnected(ByVal source As ConnectionPoint, ByVal target As ConnectionPoint)
        End Sub

        Protected Overridable Sub OnDragDrop(ByVal e As ActivityDragEventArgs)
            If (e Is Nothing) Then
                Throw New ArgumentNullException("e")
            End If
        End Sub

        Protected Overridable Sub OnDragEnter(ByVal e As ActivityDragEventArgs)
            If (e Is Nothing) Then
                Throw New ArgumentNullException("e")
            End If
        End Sub

        Protected Overridable Sub OnDragLeave()
        End Sub

        Protected Overridable Sub OnDragOver(ByVal e As ActivityDragEventArgs)
            If (e Is Nothing) Then
                Throw New ArgumentNullException("e")
            End If
        End Sub

        Protected Overridable Sub OnEndResizing()
            Me.PerformLayout
        End Sub

        Protected Friend Overridable Sub OnExecuteDesignerAction(ByVal designerAction As DesignerAction)
            If (designerAction Is Nothing) Then
                Throw New ArgumentNullException("designerAction")
            End If
            Dim service As ISelectionService = [TryCast](Me.GetService(GetType(ISelectionService)),ISelectionService)
            If (Not service Is Nothing) Then
                service.SetSelectedComponents(New Object() { Me.Activity }, SelectionTypes.Replace)
            End If
            Dim propertyName As String = designerAction.PropertyName
            If ((Not propertyName Is Nothing) AndAlso (propertyName.Length > 0)) Then
                Dim service2 As IExtendedUIService = [TryCast](Me.GetService(GetType(IExtendedUIService)),IExtendedUIService)
                If (Not service2 Is Nothing) Then
                    service2.NavigateToProperty(propertyName)
                End If
            End If
        End Sub

        Private Sub OnFirstIdle(ByVal sender As Object, ByVal e As EventArgs)
            Dim view As WorkflowView = [TryCast](DirectCast(Me, IRootDesigner).GetView(ViewTechnology.Default),WorkflowView)
            If (Not view Is Nothing) Then
                RemoveHandler view.Idle, New EventHandler(AddressOf Me.OnFirstIdle)
            End If
            Dim service As ISelectionService = DirectCast(Me.GetService(GetType(ISelectionService)), ISelectionService)
            If ((Not service Is Nothing) AndAlso (service.SelectionCount = 0)) Then
                service.SetSelectedComponents(New Object() { Me.Activity }, SelectionTypes.Replace)
            End If
            DesignerHelpers.RefreshDesignerActions(Me.Activity.Site)
            Me.Invalidate
        End Sub

        Private Sub OnGenerateEventHandler(ByVal sender As Object, ByVal e As EventArgs)
            If (TypeOf sender Is DesignerVerb AndAlso (Not Helpers.GetRootActivity(Me.Activity) Is Nothing)) Then
                Dim property As PropertyDescriptor = Nothing
                Dim descriptor2 As PropertyDescriptor
                For Each descriptor2 In Me.EventHandlerProperties
                    Dim delegateType As Type = PropertyDescriptorUtils.GetBaseType(descriptor2, Me.Activity, Me.Activity.Site)
                    If (Not delegateType Is Nothing) Then
                        Dim obj2 As Object = descriptor2.GetValue(Me.Activity)
                        If (Not TypeOf obj2 Is String OrElse String.IsNullOrEmpty(CStr(obj2))) Then
                            obj2 = DesignerHelpers.CreateUniqueMethodName(Me.Activity, descriptor2.Name, delegateType)
                        End If
                        descriptor2.SetValue(Me.Activity, obj2)
                        [property] = descriptor2
                    End If
                Next
                Dim service As IEventBindingService = [TryCast](Me.GetService(GetType(IEventBindingService)),IEventBindingService)
                If (Not service Is Nothing) Then
                    If TypeOf [property] Is DynamicPropertyDescriptor Then
                        [property] = DirectCast([property], DynamicPropertyDescriptor).RealPropertyDescriptor
                    End If
                    Dim descriptor3 As EventDescriptor = service.GetEvent([property])
                    If (Not descriptor3 Is Nothing) Then
                        service.ShowCode(Me.Activity, descriptor3)
                    Else
                        service.ShowCode
                    End If
                End If
            End If
        End Sub

        Private Sub OnGenerateEventHandlerStatusUpdate(ByVal sender As Object, ByVal e As EventArgs)
            Dim verb As DesignerVerb = [TryCast](sender,DesignerVerb)
            If (Not verb Is Nothing) Then
                Dim flag As Boolean = False
                Dim descriptor As PropertyDescriptor
                For Each descriptor In Me.EventHandlerProperties
                    If (descriptor.GetValue(Me.Activity) Is Nothing) Then
                        flag = True
                        Exit For
                    End If
                Next
                verb.Enabled = flag
            End If
        End Sub

        Protected Overridable Sub OnGiveFeedback(ByVal e As GiveFeedbackEventArgs)
            If (e Is Nothing) Then
                Throw New ArgumentNullException("e")
            End If
        End Sub

        Protected Overridable Sub OnKeyDown(ByVal e As KeyEventArgs)
            If (e Is Nothing) Then
                Throw New ArgumentNullException("e")
            End If
        End Sub

        Protected Overridable Sub OnKeyUp(ByVal e As KeyEventArgs)
            If (e Is Nothing) Then
                Throw New ArgumentNullException("e")
            End If
        End Sub

        Protected Overridable Sub OnLayoutPosition(ByVal e As ActivityDesignerLayoutEventArgs)
            If (e Is Nothing) Then
                Throw New ArgumentNullException("e")
            End If
        End Sub

        Protected Overridable Function OnLayoutSize(ByVal e As ActivityDesignerLayoutEventArgs) As Size
            If (e Is Nothing) Then
                Throw New ArgumentNullException("e")
            End If
            Me.isVisible = Me.GetVisible
            If Not String.IsNullOrEmpty(Me.Text) Then
                Dim size As Size = ActivityDesignerPaint.MeasureString(e.Graphics, e.DesignerTheme.BoldFont, Me.Text, StringAlignment.Center, Size.Empty)
                Dim size2 As Size = size
                size2.Width = (size2.Width / Me.Text.Length)
                size2.Width = (size2.Width + If(((size2.Width Mod Me.Text.Length) > 0), 1, 0))
                size2.Width = (size2.Width * Math.Min(Me.Text.Length, 7))
                Me.textSize.Width = (Me.MinimumSize.Width - (2 * e.AmbientTheme.Margin.Width))
                If (Not Me.Image Is Nothing) Then
                    Me.textSize.Width = (Me.textSize.Width - (e.DesignerTheme.ImageSize.Width + e.AmbientTheme.Margin.Width))
                End If
                Me.textSize.Width = Math.Min(Me.textSize.Width, size.Width)
                Me.textSize.Width = Math.Max(Me.textSize.Width, size2.Width)
                Me.textSize.Height = size2.Height
                Dim num As Integer = (size.Width / Me.textSize.Width)
                num = (num + If(((size.Width Mod Me.textSize.Width) > 0), 1, 0))
                num = Math.Min(num, 2)
                Me.textSize.Height = (Me.textSize.Height * num)
            Else
                Me.textSize = Size.Empty
            End If
            Dim empty As Size = Size.Empty
            empty.Width = (((2 * e.AmbientTheme.Margin.Width) + If((Not Me.Image Is Nothing), (e.DesignerTheme.ImageSize.Width + e.AmbientTheme.Margin.Width), 0)) + Me.textSize.Width)
            empty.Height = ((e.AmbientTheme.Margin.Height + Math.Max(e.DesignerTheme.ImageSize.Height, Me.textSize.Height)) + e.AmbientTheme.Margin.Height)
            Return empty
        End Function

        Private Sub OnLoadComplete(ByVal sender As Object, ByVal e As EventArgs)
            Dim view As WorkflowView = [TryCast](DirectCast(Me, IRootDesigner).GetView(ViewTechnology.Default),WorkflowView)
            If (Not view Is Nothing) Then
                AddHandler view.Idle, New EventHandler(AddressOf Me.OnFirstIdle)
            End If
        End Sub

        Protected Overridable Sub OnMouseCaptureChanged()
        End Sub

        Protected Overridable Sub OnMouseDoubleClick(ByVal e As MouseEventArgs)
            If (e Is Nothing) Then
                Throw New ArgumentNullException("e")
            End If
        End Sub

        Protected Overridable Sub OnMouseDown(ByVal e As MouseEventArgs)
            If (e Is Nothing) Then
                Throw New ArgumentNullException("e")
            End If
        End Sub

        Protected Overridable Sub OnMouseDragBegin(ByVal initialDragPoint As Point, ByVal e As MouseEventArgs)
            If (e Is Nothing) Then
                Throw New ArgumentNullException("e")
            End If
        End Sub

        Protected Overridable Sub OnMouseDragEnd()
        End Sub

        Protected Overridable Sub OnMouseDragMove(ByVal e As MouseEventArgs)
            If (e Is Nothing) Then
                Throw New ArgumentNullException("e")
            End If
        End Sub

        Protected Overridable Sub OnMouseEnter(ByVal e As MouseEventArgs)
            If (e Is Nothing) Then
                Throw New ArgumentNullException("e")
            End If
            If Me.IsVisible Then
                If Me.ShowSmartTag Then
                    Me.SmartTagVisible = True
                End If
                Me.ShowInfoTip(Me.InfoTipTitle, Me.InfoTipText)
            End If
        End Sub

        Protected Overridable Sub OnMouseHover(ByVal e As MouseEventArgs)
            If (e Is Nothing) Then
                Throw New ArgumentNullException("e")
            End If
            If Me.IsVisible Then
                Me.ShowInfoTip(Me.InfoTipTitle, Me.InfoTipText)
            End If
        End Sub

        Protected Overridable Sub OnMouseLeave()
            If Me.ShowSmartTag Then
                Me.SmartTagVisible = False
            End If
            Me.ShowInfoTip(String.Empty)
        End Sub

        Protected Overridable Sub OnMouseMove(ByVal e As MouseEventArgs)
            If (e Is Nothing) Then
                Throw New ArgumentNullException("e")
            End If
            If Me.IsVisible Then
                Me.ShowInfoTip(Me.InfoTipTitle, Me.InfoTipText)
            End If
        End Sub

        Protected Overridable Sub OnMouseUp(ByVal e As MouseEventArgs)
            If (e Is Nothing) Then
                Throw New ArgumentNullException("e")
            End If
        End Sub

        Private Sub OnMoveBranch(ByVal sender As Object, ByVal e As EventArgs)
            Dim verb As ActivityDesignerVerb = [TryCast](sender,ActivityDesignerVerb)
            If (Not verb Is Nothing) Then
                CompositeActivityDesigner.MoveDesigners(Me, CBool(verb.Properties.Item(DesignerUserDataKeys.MoveBranchKey)))
            End If
        End Sub

        Protected Overridable Sub OnPaint(ByVal e As ActivityDesignerPaintEventArgs)
            If (e Is Nothing) Then
                Throw New ArgumentNullException("e")
            End If
            ActivityDesignerPaint.DrawDesignerBackground(e.Graphics, Me)
            If (Not String.IsNullOrEmpty(Me.Text) AndAlso Not Me.TextRectangle.Size.IsEmpty) Then
                Dim font As Font = If(Me.SmartTagVisible, e.DesignerTheme.BoldFont, e.DesignerTheme.Font)
                ActivityDesignerPaint.DrawText(e.Graphics, font, Me.Text, Me.TextRectangle, StringAlignment.Near, e.AmbientTheme.TextQuality, e.DesignerTheme.ForegroundBrush)
            End If
            If ((Not Me.Image Is Nothing) AndAlso Not Me.ImageRectangle.Size.IsEmpty) Then
                ActivityDesignerPaint.DrawImage(e.Graphics, Me.Image, Me.ImageRectangle, DesignerContentAlignment.Fill)
            End If
        End Sub

        Protected Overridable Sub OnProcessMessage(ByVal message As Message)
        End Sub

        Private Sub OnPromoteBindings(ByVal sender As Object, ByVal e As EventArgs)
            If TypeOf sender Is DesignerVerb Then
                Dim service As IServiceProvider = [TryCast](Me.GetService(GetType(DesignSurface)),IServiceProvider)
                Dim customProperties As List([Of] CustomProperty) = CustomActivityDesignerHelper.GetCustomProperties(service)
                If (Not customProperties Is Nothing) Then
                    Dim customActivityType As Type = CustomActivityDesignerHelper.GetCustomActivityType(service)
                    Dim list2 As New List([Of] String)
                    Dim info As MemberInfo
                    For Each info In customActivityType.GetMembers((BindingFlags.NonPublic Or (BindingFlags.Public Or (BindingFlags.Static Or BindingFlags.Instance))))
                        If Not list2.Contains(info.Name) Then
                            list2.Add(info.Name)
                        End If
                    Next
                    Dim bindableProperties As PropertyDescriptor() = Me.BindableProperties
                    Dim dictionary As New Dictionary([Of] PropertyDescriptor, ActivityBind)
                    Dim descriptor As PropertyDescriptor
                    For Each descriptor In bindableProperties
                        If Not TypeOf descriptor.GetValue(Me.Activity) Is ActivityBind Then
                            Dim item As CustomProperty = CustomProperty.CreateCustomProperty(Me.Activity.Site, DesignerHelpers.GenerateUniqueIdentifier(Me.Activity.Site, (Me.Activity.Name & "_" & descriptor.Name), list2.ToArray), descriptor, Me.Activity)
                            customProperties.Add(item)
                            list2.Add(item.Name)
                            dictionary.Add(descriptor, New ActivityBind(ActivityBind.GetRelativePathExpression(Helpers.GetRootActivity(Me.Activity), Me.Activity), item.Name))
                        End If
                    Next
                    CustomActivityDesignerHelper.SetCustomProperties(customProperties, service)
                    Dim descriptor2 As PropertyDescriptor
                    For Each descriptor2 In dictionary.Keys
                        descriptor2.SetValue(Me.Activity, dictionary.Item(descriptor2))
                    Next
                End If
            End If
        End Sub

        Private Sub OnPromoteBindingsStatusUpdate(ByVal sender As Object, ByVal e As EventArgs)
            Dim verb As DesignerVerb = [TryCast](sender,DesignerVerb)
            If (Not verb Is Nothing) Then
                Dim flag As Boolean = False
                Dim descriptor As PropertyDescriptor
                For Each descriptor In Me.BindableProperties
                    If Not TypeOf descriptor.GetValue(Me.Activity) Is ActivityBind Then
                        flag = True
                        Exit For
                    End If
                Next
                verb.Enabled = flag
            End If
        End Sub

        Protected Overridable Sub OnQueryContinueDrag(ByVal e As QueryContinueDragEventArgs)
            If (e Is Nothing) Then
                Throw New ArgumentNullException("e")
            End If
        End Sub

        Protected Overridable Sub OnResizing(ByVal e As ActivityDesignerResizeEventArgs)
            FreeformActivityDesigner.SetDesignerBounds(Me, e.Bounds)
        End Sub

        Protected Overridable Sub OnScroll(ByVal sender As ScrollBar, ByVal value As Integer)
        End Sub

        Protected Overridable Sub OnShowSmartTagVerbs(ByVal smartTagPoint As Point)
            Dim array As ActivityDesignerVerb() = Nothing
            Me.SmartTagVerbs.CopyTo(array, 0)
            DesignerHelpers.ShowDesignerVerbs(Me, Me.PointToScreen(smartTagPoint), array)
        End Sub

        Protected Overridable Sub OnSmartTagVisibilityChanged(ByVal visible As Boolean)
            Dim bounds As Rectangle = Me.smartTag.GetBounds(Me, True)
            Dim textRectangle As Rectangle = Me.TextRectangle
            If Not textRectangle.Size.IsEmpty Then
                bounds = Rectangle.Union(textRectangle, bounds)
            End If
            Me.Invalidate(bounds)
        End Sub

        Private Sub OnStatusMoveBranch(ByVal sender As Object, ByVal e As EventArgs)
            Dim verb As ActivityDesignerVerb = [TryCast](sender,ActivityDesignerVerb)
            If (Not verb Is Nothing) Then
                Dim flag As Boolean = False
                Dim parentDesigner As CompositeActivityDesigner = Me.ParentDesigner
                If (Not Me.IsLocked AndAlso (Not parentDesigner Is Nothing)) Then
                    Dim list As New List([Of] Activity)
                    Dim activity As Activity
                    For Each activity In DirectCast(parentDesigner.Activity, CompositeActivity).Activities
                        If Not Helpers.IsAlternateFlowActivity(activity) Then
                            list.Add(activity)
                        End If
                    Next
                    Dim flag2 As Boolean = CBool(verb.Properties.Item(DesignerUserDataKeys.MoveBranchKey))
                    Dim index As Integer = list.IndexOf(Me.Activity)
                    Dim num2 As Integer = If((index > 0), (index - 1), -1)
                    flag = ((index >= 0) AndAlso (((flag2 AndAlso (index > 0)) AndAlso ((index - num2) > 0)) OrElse (Not flag2 AndAlso (index < (list.Count - 1)))))
                End If
                verb.Visible = (TypeOf parentDesigner Is ParallelActivityDesigner OrElse (TypeOf parentDesigner Is ActivityPreviewDesigner AndAlso Not Helpers.IsAlternateFlowActivity(Me.Activity)))
                verb.Enabled = flag
            End If
        End Sub

        Protected Overridable Sub OnThemeChange(ByVal newTheme As ActivityDesignerTheme)
            If (newTheme Is Nothing) Then
                Throw New ArgumentNullException("newTheme")
            End If
            Me.Image = Me.StockImage
        End Sub

        Protected Sub PerformLayout()
            Dim parentView As WorkflowView = Me.ParentView
            If (Not parentView Is Nothing) Then
                parentView.PerformLayout(False)
            End If
        End Sub

        Protected Function PointToLogical(ByVal point As Point) As Point
            Dim parentView As WorkflowView = Me.ParentView
            If (Not parentView Is Nothing) Then
                Return parentView.ScreenPointToLogical(point)
            End If
            Return point
        End Function

        Protected Function PointToScreen(ByVal point As Point) As Point
            Dim parentView As WorkflowView = Me.ParentView
            If (Not parentView Is Nothing) Then
                Return parentView.LogicalPointToScreen(point)
            End If
            Return point
        End Function

        Protected Overridable Sub PostFilterAttributes(ByVal attributes As IDictionary)
            If (attributes Is Nothing) Then
                Throw New ArgumentNullException("attributes")
            End If
        End Sub

        Protected Overridable Sub PostFilterEvents(ByVal events As IDictionary)
            If (events Is Nothing) Then
                Throw New ArgumentNullException("events")
            End If
        End Sub

        Protected Overridable Sub PostFilterProperties(ByVal properties As IDictionary)
            If (properties Is Nothing) Then
                Throw New ArgumentNullException("properties")
            End If
            Dim strings As New StringCollection
            Dim entry As DictionaryEntry
            For Each entry In properties
                Dim descriptor As PropertyDescriptor = [TryCast](entry.Value,PropertyDescriptor)
                Dim attribute As ExtenderProvidedPropertyAttribute = [TryCast](descriptor.Attributes.Item(GetType(ExtenderProvidedPropertyAttribute)),ExtenderProvidedPropertyAttribute)
                If (((Not attribute Is Nothing) AndAlso (Not attribute.Provider Is Nothing)) AndAlso Not attribute.Provider.CanExtend(Me.Activity)) Then
                    strings.Add([TryCast](entry.Key,String))
                End If
            Next
            Dim str As String
            For Each str In strings
                properties.Remove(str)
            Next
            PropertyDescriptorFilter.FilterProperties(Me.Activity.Site, Me.Activity, properties)
        End Sub

        Protected Overridable Sub PreFilterAttributes(ByVal attributes As IDictionary)
            If (attributes Is Nothing) Then
                Throw New ArgumentNullException("attributes")
            End If
        End Sub

        Protected Overridable Sub PreFilterEvents(ByVal events As IDictionary)
            If (events Is Nothing) Then
                Throw New ArgumentNullException("events")
            End If
        End Sub

        Protected Overridable Sub PreFilterProperties(ByVal properties As IDictionary)
            If (properties Is Nothing) Then
                Throw New ArgumentNullException("properties")
            End If
        End Sub

        Protected Function RectangleToLogical(ByVal rectangle As Rectangle) As Rectangle
            Dim parentView As WorkflowView = Me.ParentView
            If (Not parentView Is Nothing) Then
                Return New Rectangle(Me.PointToLogical(rectangle.Location), parentView.ClientSizeToLogical(rectangle.Size))
            End If
            Return rectangle
        End Function

        Protected Function RectangleToScreen(ByVal rectangle As Rectangle) As Rectangle
            Dim parentView As WorkflowView = Me.ParentView
            If (Not parentView Is Nothing) Then
                Return New Rectangle(Me.PointToScreen(rectangle.Location), parentView.LogicalSizeToClient(rectangle.Size))
            End If
            Return rectangle
        End Function

        Protected Friend Overridable Sub RefreshDesignerActions()
            Me.designerActions = Nothing
        End Sub

        Protected Sub RefreshDesignerVerbs()
            If ((Not Me.Activity Is Nothing) AndAlso (Not Me.Activity.Site Is Nothing)) Then
                Dim verbs As DesignerVerbCollection = DirectCast(Me, IDesigner).Verbs
                If (Not verbs Is Nothing) Then
                    Dim verb As DesignerVerb
                    For Each verb In verbs
                        Dim oleStatus As Integer = verb.OleStatus
                    Next
                End If
            End If
        End Sub

        Protected Overridable Sub SaveViewState(ByVal writer As BinaryWriter)
            If (writer Is Nothing) Then
                Throw New ArgumentNullException("writer")
            End If
        End Sub

        Protected Sub ShowInfoTip(ByVal infoTip As String)
            Dim parentView As WorkflowView = Me.ParentView
            If (Not parentView Is Nothing) Then
                parentView.ShowInfoTip(infoTip)
            End If
        End Sub

        Protected Sub ShowInfoTip(ByVal title As String, ByVal infoTip As String)
            Dim parentView As WorkflowView = Me.ParentView
            If (Not parentView Is Nothing) Then
                parentView.ShowInfoTip(title, infoTip)
            End If
        End Sub

        Protected Sub ShowInPlaceTip(ByVal infoTip As String, ByVal rectangle As Rectangle)
            Dim parentView As WorkflowView = Me.ParentView
            If (Not parentView Is Nothing) Then
                parentView.ShowInPlaceToolTip(infoTip, parentView.LogicalRectangleToClient(rectangle))
            End If
        End Sub

        Private Sub System.ComponentModel.Design.IDesigner.DoDefaultAction() Implements IDesigner.DoDefaultAction
            Me.DoDefaultAction
        End Sub

        Private Sub System.ComponentModel.Design.IDesigner.Initialize(ByVal component As IComponent) Implements IDesigner.Initialize
            Me.activity = [TryCast](component,Activity)
            If (Me.activity Is Nothing) Then
                Throw New ArgumentException(DR.GetString("Error_InvalidActivity", New Object(0  - 1) {}), "component")
            End If
            Me.Initialize(Me.activity)
        End Sub

        Private Sub System.ComponentModel.Design.IDesignerFilter.PostFilterAttributes(ByVal attributes As IDictionary) Implements IDesignerFilter.PostFilterAttributes
            Me.PostFilterAttributes(attributes)
        End Sub

        Private Sub System.ComponentModel.Design.IDesignerFilter.PostFilterEvents(ByVal events As IDictionary) Implements IDesignerFilter.PostFilterEvents
            Me.PostFilterEvents(events)
        End Sub

        Private Sub System.ComponentModel.Design.IDesignerFilter.PostFilterProperties(ByVal properties As IDictionary) Implements IDesignerFilter.PostFilterProperties
            Me.PostFilterProperties(properties)
        End Sub

        Private Sub System.ComponentModel.Design.IDesignerFilter.PreFilterAttributes(ByVal attributes As IDictionary) Implements IDesignerFilter.PreFilterAttributes
            Me.PreFilterAttributes(attributes)
        End Sub

        Private Sub System.ComponentModel.Design.IDesignerFilter.PreFilterEvents(ByVal events As IDictionary) Implements IDesignerFilter.PreFilterEvents
            Me.PreFilterEvents(events)
        End Sub

        Private Sub System.ComponentModel.Design.IDesignerFilter.PreFilterProperties(ByVal properties As IDictionary) Implements IDesignerFilter.PreFilterProperties
            Me.PreFilterProperties(properties)
        End Sub

        Private Function System.ComponentModel.Design.IRootDesigner.GetView(ByVal technology As ViewTechnology) As Object Implements IRootDesigner.GetView
            Dim service As DesignSurface = [TryCast](Me.GetService(GetType(DesignSurface)),DesignSurface)
            Dim host As IDesignerHost = [TryCast](Me.GetService(GetType(IDesignerHost)),IDesignerHost)
            If (((Me.workflowView Is Nothing) AndAlso (Not service Is Nothing)) AndAlso ((Not host Is Nothing) AndAlso (host.RootComponent Is Me.Activity))) Then
                Me.workflowView = Me.CreateView(technology)
            End If
            Return Me.workflowView
        End Function

        Private Function System.Drawing.Design.IToolboxUser.GetToolSupported(ByVal toolboxItem As ToolboxItem) As Boolean Implements IToolboxUser.GetToolSupported
            Dim flag As Boolean = True
            Dim service As ITypeProvider = [TryCast](Me.GetService(GetType(ITypeProvider)),ITypeProvider)
            If (Not service Is Nothing) Then
                Dim activityType As Type = Nothing
                If (Not service.LocalAssembly Is Nothing) Then
                    activityType = service.LocalAssembly.GetType(toolboxItem.TypeName, False)
                End If
                If (activityType Is Nothing) Then
                    Try 
                        activityType = Type.GetType((toolboxItem.TypeName & ", " & toolboxItem.AssemblyName))
                    Catch exception1 As FileNotFoundException
                    Catch exception2 As FileLoadException
                    End Try
                End If
                If (activityType Is Nothing) Then
                    Return flag
                End If
                Dim safeRootDesigner As IWorkflowRootDesigner = ActivityDesigner.GetSafeRootDesigner(Me.Activity.Site)
                If (Not safeRootDesigner Is Nothing) Then
                    If Not safeRootDesigner.IsSupportedActivityType(activityType) Then
                        Return False
                    End If
                    If ((Not safeRootDesigner.InvokingDesigner Is Nothing) AndAlso (Not safeRootDesigner.InvokingDesigner.Activity Is Nothing)) Then
                        safeRootDesigner = ActivityDesigner.GetSafeRootDesigner(safeRootDesigner.InvokingDesigner.Activity.Site)
                        If ((Not safeRootDesigner Is Nothing) AndAlso Not safeRootDesigner.IsSupportedActivityType(activityType)) Then
                            Return False
                        End If
                    End If
                End If
                If TypeOf toolboxItem Is ActivityToolboxItem Then
                    Return flag
                End If
                Dim customAttributes As Object() = activityType.GetCustomAttributes(GetType(ToolboxItemAttribute), False)
                If (customAttributes.Length <= 0) Then
                    Return flag
                End If
                flag = False
                Dim attribute As Attribute
                For Each attribute In customAttributes
                    Dim attribute2 As ToolboxItemAttribute = [TryCast](attribute,ToolboxItemAttribute)
                    If ((Not attribute2 Is Nothing) AndAlso GetType(ActivityToolboxItem).IsAssignableFrom(attribute2.ToolboxItemType)) Then
                        Return True
                    End If
                Next
            End If
            Return flag
        End Function

        Private Sub System.Drawing.Design.IToolboxUser.ToolPicked(ByVal toolboxItem As ToolboxItem) Implements IToolboxUser.ToolPicked
            Dim service As ISelectionService = [TryCast](Me.GetService(GetType(ISelectionService)),ISelectionService)
            Dim service2 As IToolboxService = [TryCast](Me.GetService(GetType(IToolboxService)),IToolboxService)
            If ((Not toolboxItem Is Nothing) AndAlso (Not service Is Nothing)) Then
                Dim primarySelection As Object = service.PrimarySelection
                If (TypeOf primarySelection Is HitTestInfo OrElse TypeOf primarySelection Is CompositeActivity) Then
                    Dim insertLocation As HitTestInfo = Nothing
                    Dim activity As CompositeActivity = Nothing
                    If TypeOf primarySelection Is HitTestInfo Then
                        insertLocation = DirectCast(primarySelection, HitTestInfo)
                        activity = [TryCast](insertLocation.AssociatedDesigner.Activity,CompositeActivity)
                    ElseIf TypeOf primarySelection Is CompositeActivity Then
                        activity = DirectCast(primarySelection, CompositeActivity)
                        insertLocation = New HitTestInfo(ActivityDesigner.GetDesigner(activity), HitTestLocations.Designer)
                    End If
                    Dim compositeActivityDesigner As CompositeActivityDesigner = [TryCast](ActivityDesigner.GetDesigner(activity),CompositeActivityDesigner)
                    If (Not compositeActivityDesigner Is Nothing) Then
                        Dim dataObj As New DataObject(service2.SerializeToolboxItem(toolboxItem))
                        Dim collection As Activity() = CompositeActivityDesigner.DeserializeActivitiesFromDataObject(Me.Activity.Site, dataObj, False)
                        If ((collection.Length <> 0) AndAlso compositeActivityDesigner.CanInsertActivities(insertLocation, New List([Of] Activity)(collection).AsReadOnly)) Then
                            Try 
                                collection = CompositeActivityDesigner.DeserializeActivitiesFromDataObject(Me.Activity.Site, dataObj, True)
                                If (collection.Length > 0) Then
                                    CompositeActivityDesigner.InsertActivities(compositeActivityDesigner, insertLocation, New List([Of] Activity)(collection).AsReadOnly, SR.GetString("PastingActivities"))
                                    service.SetSelectedComponents(collection, SelectionTypes.Replace)
                                    Me.ParentView.EnsureVisible(collection(0))
                                End If
                            Catch exception As CheckoutException
                                If (Not exception Is CheckoutException.Canceled) Then
                                    Throw New Exception((DR.GetString("ActivityInsertError", New Object(0  - 1) {}) & ChrW(10) & exception.Message), exception)
                                End If
                            End Try
                        End If
                    End If
                End If
            End If
        End Sub

        Private Function System.Workflow.ComponentModel.Design.IConnectableDesigner.CanConnect(ByVal source As ConnectionPoint, ByVal target As ConnectionPoint) As Boolean Implements IConnectableDesigner.CanConnect
            Return Me.CanConnect(source, target)
        End Function

        Private Sub System.Workflow.ComponentModel.Design.IConnectableDesigner.OnConnected(ByVal source As ConnectionPoint, ByVal target As ConnectionPoint) Implements IConnectableDesigner.OnConnected
            Me.OnConnected(source, target)
        End Sub

        Private Sub System.Workflow.ComponentModel.Design.IPersistUIState.LoadViewState(ByVal reader As BinaryReader) Implements IPersistUIState.LoadViewState
            Me.LoadViewState(reader)
        End Sub

        Private Sub System.Workflow.ComponentModel.Design.IPersistUIState.SaveViewState(ByVal writer As BinaryWriter) Implements IPersistUIState.SaveViewState
            Me.SaveViewState(writer)
        End Sub

        Private Sub System.Workflow.ComponentModel.Design.IWorkflowDesignerMessageSink.OnBeginResizing(ByVal sizingEdge As DesignerEdges) Implements IWorkflowDesignerMessageSink.OnBeginResizing
            Try 
                Me.OnBeginResizing(New ActivityDesignerResizeEventArgs(sizingEdge, Me.Bounds))
            Catch obj1 As Object
            End Try
        End Sub

        Private Function System.Workflow.ComponentModel.Design.IWorkflowDesignerMessageSink.OnDragDrop(ByVal e As DragEventArgs) As Boolean Implements IWorkflowDesignerMessageSink.OnDragDrop
            Try 
                Me.OnDragDrop([TryCast](e,ActivityDragEventArgs))
            Catch obj1 As Object
            End Try
            Return True
        End Function

        Private Function System.Workflow.ComponentModel.Design.IWorkflowDesignerMessageSink.OnDragEnter(ByVal e As DragEventArgs) As Boolean Implements IWorkflowDesignerMessageSink.OnDragEnter
            Try 
                Me.OnDragEnter([TryCast](e,ActivityDragEventArgs))
            Catch obj1 As Object
            End Try
            Return True
        End Function

        Private Function System.Workflow.ComponentModel.Design.IWorkflowDesignerMessageSink.OnDragLeave() As Boolean Implements IWorkflowDesignerMessageSink.OnDragLeave
            Try 
                Me.OnDragLeave
            Catch obj1 As Object
            End Try
            Return True
        End Function

        Private Function System.Workflow.ComponentModel.Design.IWorkflowDesignerMessageSink.OnDragOver(ByVal e As DragEventArgs) As Boolean Implements IWorkflowDesignerMessageSink.OnDragOver
            Try 
                Me.OnDragOver([TryCast](e,ActivityDragEventArgs))
            Catch obj1 As Object
            End Try
            Return True
        End Function

        Private Sub System.Workflow.ComponentModel.Design.IWorkflowDesignerMessageSink.OnEndResizing() Implements IWorkflowDesignerMessageSink.OnEndResizing
            Try 
                Me.OnEndResizing
            Catch obj1 As Object
            End Try
        End Sub

        Private Function System.Workflow.ComponentModel.Design.IWorkflowDesignerMessageSink.OnGiveFeedback(ByVal e As GiveFeedbackEventArgs) As Boolean Implements IWorkflowDesignerMessageSink.OnGiveFeedback
            Try 
                Me.OnGiveFeedback(e)
            Catch obj1 As Object
            End Try
            Return True
        End Function

        Private Function System.Workflow.ComponentModel.Design.IWorkflowDesignerMessageSink.OnKeyDown(ByVal e As KeyEventArgs) As Boolean Implements IWorkflowDesignerMessageSink.OnKeyDown
            Try 
                Me.OnKeyDown(e)
            Catch obj1 As Object
            End Try
            Return True
        End Function

        Private Function System.Workflow.ComponentModel.Design.IWorkflowDesignerMessageSink.OnKeyUp(ByVal e As KeyEventArgs) As Boolean Implements IWorkflowDesignerMessageSink.OnKeyUp
            Try 
                Me.OnKeyUp(e)
            Catch obj1 As Object
            End Try
            Return True
        End Function

        Private Sub System.Workflow.ComponentModel.Design.IWorkflowDesignerMessageSink.OnLayout(ByVal layoutEventArgs As LayoutEventArgs) Implements IWorkflowDesignerMessageSink.OnLayout
        End Sub

        Private Sub System.Workflow.ComponentModel.Design.IWorkflowDesignerMessageSink.OnLayoutPosition(ByVal graphics As Graphics) Implements IWorkflowDesignerMessageSink.OnLayoutPosition
            Try 
                Me.OnLayoutPosition(New ActivityDesignerLayoutEventArgs(graphics, Me.DesignerTheme))
            Catch obj1 As Object
            End Try
        End Sub

        Private Sub System.Workflow.ComponentModel.Design.IWorkflowDesignerMessageSink.OnLayoutSize(ByVal graphics As Graphics) Implements IWorkflowDesignerMessageSink.OnLayoutSize
            Try 
                Me.Size = Me.OnLayoutSize(New ActivityDesignerLayoutEventArgs(graphics, Me.DesignerTheme))
            Catch obj1 As Object
            End Try
        End Sub

        Private Function System.Workflow.ComponentModel.Design.IWorkflowDesignerMessageSink.OnMouseCaptureChanged() As Boolean Implements IWorkflowDesignerMessageSink.OnMouseCaptureChanged
            Try 
                Me.OnMouseCaptureChanged
            Catch obj1 As Object
            End Try
            Return True
        End Function

        Private Function System.Workflow.ComponentModel.Design.IWorkflowDesignerMessageSink.OnMouseDoubleClick(ByVal e As MouseEventArgs) As Boolean Implements IWorkflowDesignerMessageSink.OnMouseDoubleClick
            Dim parentView As WorkflowView = Me.ParentView
            If (Not parentView Is Nothing) Then
                Try 
                    Dim point As Point = parentView.ClientPointToLogical(New Point(e.X, e.Y))
                    Me.OnMouseDoubleClick(New MouseEventArgs(e.Button, e.Clicks, point.X, point.Y, e.Delta))
                Catch obj1 As Object
                End Try
            End If
            Return True
        End Function

        Private Function System.Workflow.ComponentModel.Design.IWorkflowDesignerMessageSink.OnMouseDown(ByVal e As MouseEventArgs) As Boolean Implements IWorkflowDesignerMessageSink.OnMouseDown
            Dim parentView As WorkflowView = Me.ParentView
            If (Not parentView Is Nothing) Then
                Try 
                    Dim point As Point = parentView.ClientPointToLogical(New Point(e.X, e.Y))
                    Me.OnMouseDown(New MouseEventArgs(e.Button, e.Clicks, point.X, point.Y, e.Delta))
                Catch obj1 As Object
                End Try
            End If
            Return True
        End Function

        Private Function System.Workflow.ComponentModel.Design.IWorkflowDesignerMessageSink.OnMouseDragBegin(ByVal initialPoint As Point, ByVal e As MouseEventArgs) As Boolean Implements IWorkflowDesignerMessageSink.OnMouseDragBegin
            Dim parentView As WorkflowView = Me.ParentView
            If (Not parentView Is Nothing) Then
                Try 
                    Dim point As Point = parentView.ClientPointToLogical(New Point(e.X, e.Y))
                    Me.OnMouseDragBegin(initialPoint, New MouseEventArgs(e.Button, e.Clicks, point.X, point.Y, e.Delta))
                Catch obj1 As Object
                End Try
            End If
            Return True
        End Function

        Private Function System.Workflow.ComponentModel.Design.IWorkflowDesignerMessageSink.OnMouseDragEnd() As Boolean Implements IWorkflowDesignerMessageSink.OnMouseDragEnd
            Try 
                Me.OnMouseDragEnd
            Catch obj1 As Object
            End Try
            Return True
        End Function

        Private Function System.Workflow.ComponentModel.Design.IWorkflowDesignerMessageSink.OnMouseDragMove(ByVal e As MouseEventArgs) As Boolean Implements IWorkflowDesignerMessageSink.OnMouseDragMove
            Dim parentView As WorkflowView = Me.ParentView
            If (Not parentView Is Nothing) Then
                Try 
                    Dim point As Point = parentView.ClientPointToLogical(New Point(e.X, e.Y))
                    Me.OnMouseDragMove(New MouseEventArgs(e.Button, e.Clicks, point.X, point.Y, e.Delta))
                Catch obj1 As Object
                End Try
            End If
            Return True
        End Function

        Private Function System.Workflow.ComponentModel.Design.IWorkflowDesignerMessageSink.OnMouseEnter(ByVal e As MouseEventArgs) As Boolean Implements IWorkflowDesignerMessageSink.OnMouseEnter
            Dim parentView As WorkflowView = Me.ParentView
            If (Not parentView Is Nothing) Then
                Try 
                    Dim point As Point = parentView.ClientPointToLogical(New Point(e.X, e.Y))
                    Me.OnMouseEnter(New MouseEventArgs(e.Button, e.Clicks, point.X, point.Y, e.Delta))
                Catch obj1 As Object
                End Try
            End If
            Return True
        End Function

        Private Function System.Workflow.ComponentModel.Design.IWorkflowDesignerMessageSink.OnMouseHover(ByVal e As MouseEventArgs) As Boolean Implements IWorkflowDesignerMessageSink.OnMouseHover
            Dim parentView As WorkflowView = Me.ParentView
            If (Not parentView Is Nothing) Then
                Try 
                    Dim point As Point = parentView.ClientPointToLogical(New Point(e.X, e.Y))
                    Me.OnMouseHover(New MouseEventArgs(e.Button, e.Clicks, point.X, point.Y, e.Delta))
                Catch obj1 As Object
                End Try
            End If
            Return True
        End Function

        Private Function System.Workflow.ComponentModel.Design.IWorkflowDesignerMessageSink.OnMouseLeave() As Boolean Implements IWorkflowDesignerMessageSink.OnMouseLeave
            Try 
                Me.OnMouseLeave
            Catch obj1 As Object
            End Try
            Return True
        End Function

        Private Function System.Workflow.ComponentModel.Design.IWorkflowDesignerMessageSink.OnMouseMove(ByVal e As MouseEventArgs) As Boolean Implements IWorkflowDesignerMessageSink.OnMouseMove
            Dim parentView As WorkflowView = Me.ParentView
            If (Not parentView Is Nothing) Then
                Try 
                    Dim point As Point = parentView.ClientPointToLogical(New Point(e.X, e.Y))
                    Me.OnMouseMove(New MouseEventArgs(e.Button, e.Clicks, point.X, point.Y, e.Delta))
                Catch obj1 As Object
                End Try
            End If
            Return True
        End Function

        Private Function System.Workflow.ComponentModel.Design.IWorkflowDesignerMessageSink.OnMouseUp(ByVal e As MouseEventArgs) As Boolean Implements IWorkflowDesignerMessageSink.OnMouseUp
            Dim parentView As WorkflowView = Me.ParentView
            If (Not parentView Is Nothing) Then
                Try 
                    Dim point As Point = parentView.ClientPointToLogical(New Point(e.X, e.Y))
                    Me.OnMouseUp(New MouseEventArgs(e.Button, e.Clicks, point.X, point.Y, e.Delta))
                Catch obj1 As Object
                End Try
            End If
            Return True
        End Function

        Private Function System.Workflow.ComponentModel.Design.IWorkflowDesignerMessageSink.OnMouseWheel(ByVal e As MouseEventArgs) As Boolean Implements IWorkflowDesignerMessageSink.OnMouseWheel
            Return True
        End Function

        Private Function System.Workflow.ComponentModel.Design.IWorkflowDesignerMessageSink.OnPaint(ByVal e As PaintEventArgs, ByVal viewPort As Rectangle) As Boolean Implements IWorkflowDesignerMessageSink.OnPaint
            Try 
                Dim bounds As Rectangle = Me.Bounds
                If (Me.IsVisible AndAlso viewPort.IntersectsWith(bounds)) Then
                    Dim service As GlyphManager = [TryCast](Me.GetService(GetType(IDesignerGlyphProviderService)),GlyphManager)
                    bounds.Width += 1
                    bounds.Height += 1
                    [Using] path As GraphicsPath = ActivityDesignerPaint.GetDesignerPath(Me, Point.Empty, New Size(Me.DesignerTheme.BorderWidth, Me.DesignerTheme.BorderWidth), DesignerEdges.All, False)
                        [Using] region As Region = New Region(path)
                            Dim clip As Region = e.Graphics.Clip
                            [region].Intersect(clip)
                            [region].Intersect(viewPort)
                            Dim flag As Boolean = False
                            Try 
                                Dim args As New ActivityDesignerPaintEventArgs(e.Graphics, bounds, viewPort, Me.DesignerTheme)
                                e.Graphics.Clip = [region]
                                Me.OnPaint(args)
                                e.Graphics.Clip = clip
                                flag = True
                                If (Not service Is Nothing) Then
                                    service.DrawDesignerGlyphs(args, Me)
                                End If
                                Me.DrawingState = (Me.DrawingState And Not DrawingStates.InvalidDraw)
                            Catch obj1 As Object
                                Me.DrawingState = (Me.DrawingState Or DrawingStates.InvalidDraw)
                            Finally
                                If Not flag Then
                                    e.Graphics.Clip = clip
                                End If
                                If (Me.DrawingState <> DrawingStates.Valid) Then
                                    ActivityDesignerPaint.DrawInvalidDesignerIndicator(e.Graphics, Me)
                                End If
                            End Try
                        End [Using]
                    End [Using]
                End If
            Catch obj2 As Object
            End Try
            Return True
        End Function

        Private Function System.Workflow.ComponentModel.Design.IWorkflowDesignerMessageSink.OnPaintWorkflowAdornments(ByVal e As PaintEventArgs, ByVal viewPort As Rectangle) As Boolean Implements IWorkflowDesignerMessageSink.OnPaintWorkflowAdornments
            Return True
        End Function

        Private Function System.Workflow.ComponentModel.Design.IWorkflowDesignerMessageSink.OnQueryContinueDrag(ByVal e As QueryContinueDragEventArgs) As Boolean Implements IWorkflowDesignerMessageSink.OnQueryContinueDrag
            Try 
                Me.OnQueryContinueDrag(e)
            Catch obj1 As Object
            End Try
            Return True
        End Function

        Private Sub System.Workflow.ComponentModel.Design.IWorkflowDesignerMessageSink.OnResizing(ByVal sizingEdge As DesignerEdges, ByVal bounds As Rectangle) Implements IWorkflowDesignerMessageSink.OnResizing
            Try 
                Me.OnResizing(New ActivityDesignerResizeEventArgs(sizingEdge, bounds))
            Catch obj1 As Object
            End Try
        End Sub

        Private Function System.Workflow.ComponentModel.Design.IWorkflowDesignerMessageSink.OnScroll(ByVal sender As ScrollBar, ByVal value As Integer) As Boolean Implements IWorkflowDesignerMessageSink.OnScroll
            Try 
                Me.OnScroll(sender, value)
            Catch obj1 As Object
            End Try
            Return True
        End Function

        Private Function System.Workflow.ComponentModel.Design.IWorkflowDesignerMessageSink.OnShowContextMenu(ByVal screenMenuPoint As Point) As Boolean Implements IWorkflowDesignerMessageSink.OnShowContextMenu
            Return True
        End Function

        Private Sub System.Workflow.ComponentModel.Design.IWorkflowDesignerMessageSink.OnThemeChange() Implements IWorkflowDesignerMessageSink.OnThemeChange
            Try 
                Me.OnThemeChange(Me.DesignerTheme)
            Catch obj1 As Object
            End Try
        End Sub

        Private Function System.Workflow.ComponentModel.Design.IWorkflowDesignerMessageSink.ProcessMessage(ByVal message As Message) As Boolean Implements IWorkflowDesignerMessageSink.ProcessMessage
            Try 
                Me.OnProcessMessage(message)
            Catch obj1 As Object
            End Try
            Return True
        End Function

        Private Function System.Workflow.ComponentModel.Design.IWorkflowRootDesigner.IsSupportedActivityType(ByVal activityType As Type) As Boolean Implements IWorkflowRootDesigner.IsSupportedActivityType
            Return Me.IsSupportedActivityType(activityType)
        End Function


        ' Properties
        Public Overridable ReadOnly Property AccessibilityObject As AccessibleObject
            Get
                If (Me.accessibilityObject Is Nothing) Then
                    Me.accessibilityObject = New ActivityDesignerAccessibleObject(Me)
                End If
                Return Me.accessibilityObject
            End Get
        End Property

        Public ReadOnly Property Activity As Activity
            Get
                Return Me.activity
            End Get
        End Property

        Private ReadOnly Property BindableProperties As PropertyDescriptor()
            Get
                Dim list As New List([Of] PropertyDescriptor)
                If Not Helpers.IsActivityLocked(Me.Activity) Then
                    Dim properties As PropertyDescriptorCollection = TypeDescriptor.GetProperties(Me.Activity, New Attribute() { New BrowsableAttribute(True) })
                    If (Not properties Is Nothing) Then
                        Dim descriptor As PropertyDescriptor
                        For Each descriptor In properties
                            If TypeOf descriptor.Converter Is ActivityBindTypeConverter Then
                                list.Add(descriptor)
                            End If
                        Next
                    End If
                End If
                Return list.ToArray
            End Get
        End Property

        Public ReadOnly Property Bounds As Rectangle
            Get
                Return New Rectangle(Me.Location, Me.Size)
            End Get
        End Property

        Protected Friend Overridable ReadOnly Property DesignerActions As ReadOnlyCollection([Of] DesignerAction)
            Get
                If (Me.designerActions Is Nothing) Then
                    Me.designerActions = New List([Of] DesignerAction)
                    Dim activity As Activity = Me.Activity
                    If (Not activity Is Nothing) Then
                        Dim flag As Boolean = ActivityDesigner.IsCommentedActivity(activity)
                        Dim service As WorkflowDesignerLoader = [TryCast](Me.GetService(GetType(WorkflowDesignerLoader)),WorkflowDesignerLoader)
                        Dim flag2 As Boolean = ((Not service Is Nothing) AndAlso service.InDebugMode)
                        If (((activity.Enabled AndAlso Not flag) AndAlso (Not Me.IsLocked AndAlso (Not activity.Site Is Nothing))) AndAlso Not flag2) Then
                            Dim errors As New ValidationErrorCollection
                            Try 
                                Dim manager As New ValidationManager(Me.Activity.Site, False)
                                Helpers.GetRootActivity(Me.Activity)
                                Dim validator As Validator
                                For Each validator In manager.GetValidators(activity.GetType)
                                    errors.AddRange(validator.Validate(manager, activity))
                                Next
                            Catch obj1 As Object
                            End Try
                            If (errors.Count > 0) Then
                                Dim i As Integer
                                For i = 0 To errors.Count - 1
                                    Dim error As ValidationError = errors.Item(i)
                                    If ((Not [error] Is Nothing) AndAlso Not [error].IsWarning) Then
                                        Dim item As New DesignerAction(Me, i, [error].ErrorText, AmbientTheme.ConfigErrorImage) { _
                                            .PropertyName = [error].PropertyName _
                                        }
                                        Dim entry As DictionaryEntry
                                        For Each entry In [error].UserData
                                            item.UserData.Item(entry.Key) = entry.Value
                                        Next
                                        Me.designerActions.Add(item)
                                    End If
                                Next i
                            End If
                        End If
                    End If
                End If
                Return Me.designerActions.AsReadOnly
            End Get
        End Property

        Friend ReadOnly Property DesignerSmartTag As SmartTag
            Get
                Return Me.smartTag
            End Get
        End Property

        Public ReadOnly Property DesignerTheme As ActivityDesignerTheme
            Get
                Return WorkflowTheme.CurrentTheme.GetDesignerTheme(Me)
            End Get
        End Property

        Friend Property DrawingState As DrawingStates
            Get
                Return Me.drawingState
            End Get
            Set(ByVal value As DrawingStates)
                Me.drawingState = value
            End Set
        End Property

        Protected Friend Overridable ReadOnly Property EnableVisualResizing As Boolean
            Get
                Return False
            End Get
        End Property

        Private ReadOnly Property EventHandlerProperties As PropertyDescriptor()
            Get
                Dim list As New List([Of] PropertyDescriptor)
                If (Not Me.Activity.Site Is Nothing) Then
                    Dim descriptor As PropertyDescriptor
                    For Each descriptor In PropertyDescriptorFilter.GetPropertiesForEvents(Me.Activity.Site, Me.Activity)
                        list.Add(descriptor)
                    Next
                End If
                Return list.ToArray
            End Get
        End Property

        Protected Friend Overridable ReadOnly Property Glyphs As ActivityDesignerGlyphCollection
            Get
                Dim glyphs As New ActivityDesignerGlyphCollection
                If Me.IsSelected Then
                    If Me.IsPrimarySelection Then
                        glyphs.Add(PrimarySelectionGlyph.Default)
                    Else
                        glyphs.Add(NonPrimarySelectionGlyph.Default)
                    End If
                End If
                Dim flag As Boolean = ActivityDesigner.IsCommentedActivity(Me.Activity)
                Dim service As WorkflowDesignerLoader = [TryCast](Me.GetService(GetType(WorkflowDesignerLoader)),WorkflowDesignerLoader)
                Dim flag2 As Boolean = ((Not service Is Nothing) AndAlso service.InDebugMode)
                If (((WorkflowTheme.CurrentTheme.AmbientTheme.ShowConfigErrors AndAlso Me.Activity.Enabled) AndAlso (Not flag AndAlso Not flag2)) AndAlso (Me.DesignerActions.Count > 0)) Then
                    glyphs.Add(ConfigErrorGlyph.Default)
                End If
                If (Not Me.Activity.Enabled AndAlso Not flag) Then
                    glyphs.Add(CommentGlyph.Default)
                End If
                If Helpers.IsActivityLocked(Me.Activity) Then
                    glyphs.Add(LockedActivityGlyph.Default)
                End If
                If (Me.SmartTagVisible AndAlso Me.ShowSmartTag) Then
                    glyphs.Add(Me.smartTag)
                End If
                Return glyphs
            End Get
        End Property

        Property Image As Image
            Public Overridable Get
                Return Me.image
            End Get
            Protected Overridable Set(ByVal value As Image)
                Me.image = value
                Me.PerformLayout
            End Set
        End Property

        Protected Overridable ReadOnly Property ImageRectangle As Rectangle
            Get
                If (Me.Image Is Nothing) Then
                    Return Rectangle.Empty
                End If
                Dim ambientTheme As AmbientTheme = WorkflowTheme.CurrentTheme.AmbientTheme
                Dim designerTheme As ActivityDesignerTheme = Me.DesignerTheme
                Dim bounds As Rectangle = Me.Bounds
                Dim empty As Rectangle = Rectangle.Empty
                empty.X = (bounds.Left + WorkflowTheme.CurrentTheme.AmbientTheme.Margin.Width)
                empty.Y = (bounds.Top + ((bounds.Height - Me.DesignerTheme.ImageSize.Height) / 2))
                empty.Size = designerTheme.ImageSize
                Return empty
            End Get
        End Property

        Private ReadOnly Property InfoTipText As String
            Get
                Dim str As String = If(Not String.IsNullOrEmpty(Me.Activity.Description), Me.Activity.Description, ActivityDesigner.GetActivityDescription(Me.Activity.GetType))
                str = If((str.Length > 80), (str.Substring(0, 80) & "..."), str)
                If (Me.RulesText.Length > 0) Then
                    str = (str & ChrW(10) & ChrW(10) & Me.RulesText)
                End If
                Return str
            End Get
        End Property

        Private ReadOnly Property InfoTipTitle As String
            Get
                If (Me.Activity.Parent Is Nothing) Then
                    Return Me.Activity.GetType.Name
                End If
                Dim str2 As String = If((Me.Activity.Name.Length > &H19), (Me.Activity.Name.Substring(0, &H19) & "..."), Me.Activity.Name)
                Return DR.GetString("InfoTipTitle", New Object() { Me.Activity.GetType.Name, str2 })
            End Get
        End Property

        Protected Overridable Property InvokingDesigner As CompositeActivityDesigner
            Get
                Return Me.invokingDesigner
            End Get
            Set(ByVal value As CompositeActivityDesigner)
                Me.invokingDesigner = value
            End Set
        End Property

        Public ReadOnly Property IsLocked As Boolean
            Get
                If Helpers.IsActivityLocked(Me.Activity) Then
                    Return True
                End If
                If (Me.DrawingState <> DrawingStates.Valid) Then
                    Return True
                End If
                Dim service As WorkflowDesignerLoader = [TryCast](Me.GetService(GetType(WorkflowDesignerLoader)),WorkflowDesignerLoader)
                If ((Not service Is Nothing) AndAlso service.InDebugMode) Then
                    Return True
                End If
                Dim safeRootDesigner As IWorkflowRootDesigner = ActivityDesigner.GetSafeRootDesigner(Me.Activity.Site)
                Return ((Not safeRootDesigner Is Nothing) AndAlso (Not safeRootDesigner.InvokingDesigner Is Nothing))
            End Get
        End Property

        Public ReadOnly Property IsPrimarySelection As Boolean
            Get
                Dim service As ISelectionService = [TryCast](Me.GetService(GetType(ISelectionService)),ISelectionService)
                Return ((Not service Is Nothing) AndAlso (service.PrimarySelection Is Me.Activity))
            End Get
        End Property

        Public ReadOnly Property IsRootDesigner As Boolean
            Get
                Dim flag As Boolean = False
                Dim service As IDesignerHost = [TryCast](Me.GetService(GetType(IDesignerHost)),IDesignerHost)
                If (Not service Is Nothing) Then
                    flag = (service.RootComponent Is Me.Activity)
                End If
                Return flag
            End Get
        End Property

        Public ReadOnly Property IsSelected As Boolean
            Get
                Dim service As ISelectionService = [TryCast](Me.GetService(GetType(ISelectionService)),ISelectionService)
                Return ((Not service Is Nothing) AndAlso service.GetComponentSelected(Me.Activity))
            End Get
        End Property

        Public Overridable ReadOnly Property IsVisible As Boolean
            Get
                Return Me.isVisible
            End Get
        End Property

        Public Overridable Property Location As Point
            Get
                Return Me.location
            End Get
            Set(ByVal value As Point)
                If TypeOf Me.ParentDesigner Is FreeformActivityDesigner Then
                    value = DesignerHelpers.SnapToGrid(value)
                End If
                If (Me.location <> value) Then
                    Me.location = value
                End If
            End Set
        End Property

        Protected Overridable ReadOnly Property MessageFilters As ReadOnlyCollection([Of] WorkflowDesignerMessageFilter)
            Get
                Return New List([Of] WorkflowDesignerMessageFilter)() { New ConnectionManager(), New ResizingMessageFilter(), New DynamicActionMessageFilter(), New AutoScrollingMessageFilter(), New AutoExpandingMessageFilter(), New DragSelectionMessageFilter(), New FreeFormDragDropManager() }.AsReadOnly
            End Get
        End Property

        Public Overridable ReadOnly Property MinimumSize As Size
            Get
                Return Me.DesignerTheme.Size
            End Get
        End Property

        <EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)> _
        Friend Property Name As String
            Get
                If (Me.Activity Is Nothing) Then
                    Return Nothing
                End If
                Return Me.Activity.Name
            End Get
            Set(ByVal value As String)
            End Set
        End Property

        Public ReadOnly Property ParentDesigner As CompositeActivityDesigner
            Get
                Dim designer As CompositeActivityDesigner = Nothing
                Dim designer2 As IWorkflowRootDesigner = Me
                If ((Not designer2 Is Nothing) AndAlso Me.IsRootDesigner) Then
                    Return designer2.InvokingDesigner
                End If
                If ((Not Me.Activity Is Nothing) AndAlso (Not Me.Activity.Parent Is Nothing)) Then
                    designer = [TryCast](ActivityDesigner.GetDesigner(Me.Activity.Parent),CompositeActivityDesigner)
                End If
                Return designer
            End Get
        End Property

        Protected Friend ReadOnly Property ParentView As WorkflowView
            Get
                Return [TryCast](Me.GetService(GetType(WorkflowView)),WorkflowView)
            End Get
        End Property

        Private ReadOnly Property RulesText As String
            Get
                If (Me.rulesText Is Nothing) Then
                    Me.rulesText = String.Empty
                    Dim declarativeRules As IDictionary([Of] String, String) = DesignerHelpers.GetDeclarativeRules(Me.Activity)
                    If (declarativeRules.Count > 0) Then
                        Me.rulesText = DR.GetString("Rules", New Object(0  - 1) {})
                        Dim num As Integer = &H13B
                        Dim pair As KeyValuePair([Of] String, String)
                        For Each pair In declarativeRules
                            Me.rulesText = (Me.rulesText & ChrW(10))
                            Dim key As String = pair.Key
                            key = If((key.Length > &H19), (key.Substring(0, &H19) & "..."), key)
                            Dim str2 As String = pair.Value
                            str2 = If((str2.Length > 80), (str2.Substring(0, 80) & "..."), str2)
                            If (str2.Length = 0) Then
                                str2 = DR.GetString("Empty", New Object(0  - 1) {})
                            End If
                            Me.rulesText = (Me.rulesText & String.Format(CultureInfo.CurrentCulture, "{0}: {1}", New Object() { key, str2 }))
                            If (Me.rulesText.Length > num) Then
                                Exit For
                            End If
                        Next
                        If (Me.rulesText.Length > num) Then
                            Me.rulesText = (Me.rulesText & ChrW(10) & ChrW(10) & DR.GetString("More", New Object(0  - 1) {}))
                        End If
                    End If
                End If
                Return Me.rulesText
            End Get
        End Property

        Protected Overridable ReadOnly Property ShowSmartTag As Boolean
            Get
                Return False
            End Get
        End Property

        Public Overridable Property Size As Size
            Get
                Return Me.size
            End Get
            Set(ByVal value As Size)
                value.Width = Math.Max(value.Width, Me.MinimumSize.Width)
                value.Height = Math.Max(value.Height, Me.MinimumSize.Height)
                If (Me.size <> value) Then
                    Me.size = value
                End If
            End Set
        End Property

        Protected Overridable ReadOnly Property SmartTagRectangle As Rectangle
            Get
                Dim empty As Rectangle = Rectangle.Empty
                Dim imageRectangle As Rectangle = Me.ImageRectangle
                If Not imageRectangle.Size.IsEmpty Then
                    empty = imageRectangle
                End If
                Return empty
            End Get
        End Property

        Protected Overridable ReadOnly Property SmartTagVerbs As ReadOnlyCollection([Of] ActivityDesignerVerb)
            Get
                Return New List([Of] ActivityDesignerVerb)().AsReadOnly
            End Get
        End Property

        Friend Overridable Property SmartTagVisible As Boolean
            Get
                Return ((Me.ShowSmartTag AndAlso (Not Me.smartTag.ActiveDesigner Is Nothing)) OrElse Me.smartTagVisible)
            End Get
            Set(ByVal value As Boolean)
                If (Me.smartTagVisible <> value) Then
                    Me.smartTagVisible = value
                    Me.OnSmartTagVisibilityChanged(Me.smartTagVisible)
                End If
            End Set
        End Property

        Friend ReadOnly Property StockImage As Image
            Get
                If (Me.Activity Is Nothing) Then
                    Return Nothing
                End If
                Dim designerImage As Image = Me.DesignerTheme.DesignerImage
                If (designerImage Is Nothing) Then
                    designerImage = ActivityToolboxItem.GetToolboxImage(Me.Activity.GetType)
                End If
                Return designerImage
            End Get
        End Property

        Friend Overridable ReadOnly Property SupportedLayout As WorkflowLayout
            Get
                Return New ActivityRootLayout(Me.Activity.Site)
            End Get
        End Property

        Friend Overridable ReadOnly Property SupportsLayoutPersistence As Boolean
            Get
                Dim service As IDesignerHost = [TryCast](Me.GetService(GetType(IDesignerHost)),IDesignerHost)
                If (Not service Is Nothing) Then
                    Dim component As IComponent
                    For Each component In service.Container.Components
                        Dim activity As Activity = [TryCast](component,Activity)
                        If ((Not activity Is Nothing) AndAlso TypeOf ActivityDesigner.GetDesigner(activity) Is FreeformActivityDesigner) Then
                            Return True
                        End If
                    Next
                End If
                Return False
            End Get
        End Property

        Private ReadOnly Property System.ComponentModel.Design.IDesigner.Component As IComponent
            Get
                Return Me.activity
            End Get
        End Property

        Private ReadOnly Property System.ComponentModel.Design.IDesigner.Verbs As DesignerVerbCollection
            Get
                Dim verbs As New ActivityDesignerVerbCollection
                verbs.AddRange(Me.Verbs)
                Dim service As IDesignerVerbProviderService = [TryCast](Me.GetService(GetType(IDesignerVerbProviderService)),IDesignerVerbProviderService)
                If (Not service Is Nothing) Then
                    Dim provider As IDesignerVerbProvider
                    For Each provider In service.VerbProviders
                        verbs.AddRange(provider.GetVerbs(Me))
                    Next
                End If
                Return verbs.SafeCollection
            End Get
        End Property

        Private ReadOnly Property System.ComponentModel.Design.IRootDesigner.SupportedTechnologies As ViewTechnology()
            Get
                Return New ViewTechnology() { ViewTechnology.Default }
            End Get
        End Property

        Private Property System.Workflow.ComponentModel.Design.IWorkflowRootDesigner.InvokingDesigner As CompositeActivityDesigner
            Get
                Return Me.InvokingDesigner
            End Get
            Set(ByVal value As CompositeActivityDesigner)
                Me.InvokingDesigner = value
            End Set
        End Property

        Private ReadOnly Property System.Workflow.ComponentModel.Design.IWorkflowRootDesigner.MessageFilters As ReadOnlyCollection([Of] WorkflowDesignerMessageFilter)
            Get
                Return Me.MessageFilters
            End Get
        End Property

        Private ReadOnly Property System.Workflow.ComponentModel.Design.IWorkflowRootDesigner.SupportsLayoutPersistence As Boolean
            Get
                Return Me.SupportsLayoutPersistence
            End Get
        End Property

        Property [Text] As String
            Public Overridable Get
                Return Me.text
            End Get
            Protected Overridable Set(ByVal value As String)
                If (((Not value Is Nothing) AndAlso (value.Length <> 0)) AndAlso (Me.text <> value)) Then
                    Me.text = value
                    Me.PerformLayout
                End If
            End Set
        End Property

        Protected Overridable ReadOnly Property TextRectangle As Rectangle
            Get
                If String.IsNullOrEmpty(Me.Text) Then
                    Return Rectangle.Empty
                End If
                Dim ambientTheme As AmbientTheme = WorkflowTheme.CurrentTheme.AmbientTheme
                Dim designerTheme As ActivityDesignerTheme = Me.DesignerTheme
                Dim bounds As Rectangle = Me.Bounds
                Dim empty As Rectangle = Rectangle.Empty
                empty.X = (bounds.Left + ambientTheme.Margin.Width)
                empty.X = (empty.X + If((Not Me.Image Is Nothing), (designerTheme.ImageSize.Width + ambientTheme.Margin.Width), 0))
                empty.Y = (bounds.Top + ((bounds.Height - Me.textSize.Height) / 2))
                empty.Size = Me.textSize
                Return empty
            End Get
        End Property

        Protected Overridable ReadOnly Property Verbs As ActivityDesignerVerbCollection
            Get
                If (Me.designerVerbs Is Nothing) Then
                    Me.designerVerbs = New ActivityDesignerVerbCollection
                    If Not Me.IsLocked Then
                        Me.designerVerbs.Add(New ActivityDesignerVerb(Me, DesignerVerbGroup.General, DR.GetString("GenerateEventHandlers", New Object(0  - 1) {}), New EventHandler(AddressOf Me.OnGenerateEventHandler), New EventHandler(AddressOf Me.OnGenerateEventHandlerStatusUpdate)))
                    End If
                    Me.GetService(GetType(WorkflowDesignerLoader))
                    If (Not Me.Activity.Parent Is Nothing) Then
                        Me.designerVerbs.Add(New ActivityDesignerVerb(Me, DesignerVerbGroup.General, DR.GetString("PromoteBindings", New Object(0  - 1) {}), New EventHandler(AddressOf Me.OnPromoteBindings), New EventHandler(AddressOf Me.OnPromoteBindingsStatusUpdate)))
                    End If
                    Me.designerVerbs.Add(New ActivityDesignerVerb(Me, DesignerVerbGroup.General, DR.GetString("BindSelectedProperty", New Object(0  - 1) {}), New EventHandler(AddressOf Me.OnBindProperty), New EventHandler(AddressOf Me.OnBindPropertyStatusUpdate)))
                    Dim verb As New ActivityDesignerVerb(Me, DesignerVerbGroup.General, DR.GetString("MoveLeftDesc", New Object(0  - 1) {}), New EventHandler(AddressOf Me.OnMoveBranch), New EventHandler(AddressOf Me.OnStatusMoveBranch))
                    verb.Properties.Item(DesignerUserDataKeys.MoveBranchKey) = True
                    Me.designerVerbs.Add(verb)
                    verb = New ActivityDesignerVerb(Me, DesignerVerbGroup.General, DR.GetString("MoveRightDesc", New Object(0  - 1) {}), New EventHandler(AddressOf Me.OnMoveBranch), New EventHandler(AddressOf Me.OnStatusMoveBranch))
                    verb.Properties.Item(DesignerUserDataKeys.MoveBranchKey) = False
                    Me.designerVerbs.Add(verb)
                    Dim verb2 As ActivityDesignerVerb
                    For Each verb2 In Me.SmartTagVerbs
                        Me.designerVerbs.Add(verb2)
                    Next
                End If
                Return Me.designerVerbs
            End Get
        End Property


        ' Fields
        Private accessibilityObject As ActivityDesignerAccessibleObject
        Private activity As Activity
        Private designerActions As List([Of] DesignerAction)
        Private designerVerbs As ActivityDesignerVerbCollection
        Private drawingState As DrawingStates
        Private image As Image
        Private invokingDesigner As CompositeActivityDesigner
        Private isVisible As Boolean = True
        Private location As Point = Point.Empty
        Private Const MaximumCharsPerLine As Integer = 8
        Private Const MaximumDescriptionLength As Integer = 80
        Private Const MaximumIdentifierLength As Integer = &H19
        Private Const MaximumTextLines As Integer = 2
        Private rulesText As String
        Private size As Size = Size.Empty
        Private smartTag As SmartTag = New SmartTag
        Private smartTagVisible As Boolean
        Private [text] As String = String.Empty
        Private textSize As Size = Size.Empty
        Private workflowView As WorkflowView

        ' Nested Types
        <Flags> _
        Friend Enum DrawingStates
            ' Fields
            InvalidDraw = 4
            InvalidPosition = 1
            InvalidSize = 2
            Valid = 0
        End Enum

        Friend NotInheritable Class SmartTag
            Inherits DesignerGlyph
            ' Methods
            Public Overrides Function GetBounds(ByVal designer As ActivityDesigner, ByVal activated As Boolean) As Rectangle
                Dim empty As Rectangle = Rectangle.Empty
                Dim smartTagRectangle As Rectangle = designer.SmartTagRectangle
                If Not smartTagRectangle.IsEmpty Then
                    Dim glyphSize As Size = WorkflowTheme.CurrentTheme.AmbientTheme.GlyphSize
                    Dim size As Size = smartTagRectangle.Size
                    Dim margin As Size = WorkflowTheme.CurrentTheme.AmbientTheme.Margin
                    empty.X = (smartTagRectangle.Left - (margin.Width / 2))
                    empty.Y = (smartTagRectangle.Top - (margin.Height / 2))
                    empty.Width = ((size.Width + (glyphSize.Width / 2)) + (3 * margin.Width))
                    empty.Height = (size.Height + margin.Height)
                End If
                Return empty
            End Function

            Protected Overrides Sub OnActivate(ByVal designer As ActivityDesigner)
                If (designer.SmartTagVerbs.Count > 0) Then
                    Me.activeDesigner = designer
                    Dim bounds As Rectangle = Me.GetBounds(designer, True)
                    Me.activeDesigner.OnShowSmartTagVerbs(New Point(bounds.Left, (bounds.Bottom + 1)))
                    Me.activeDesigner = Nothing
                End If
            End Sub

            Protected Overrides Sub OnPaint(ByVal graphics As Graphics, ByVal activated As Boolean, ByVal ambientTheme As AmbientTheme, ByVal designer As ActivityDesigner)
                Dim bounds As Rectangle = Me.GetBounds(designer, True)
                Dim flag As Boolean = False
                If ((Not Form.ActiveForm Is Nothing) AndAlso Form.ActiveForm.GetType.FullName.Equals((GetType(ItemPalette).FullName & "+Palette"), StringComparison.Ordinal)) Then
                    flag = (Form.ActiveForm.Location = designer.PointToScreen(New Point(bounds.Left, bounds.Bottom)))
                End If
                If Not activated Then
                    If (Not Me.activeDesigner Is Nothing) Then
                        activated = True
                    ElseIf ((Not Form.ActiveForm Is Nothing) AndAlso Form.ActiveForm.GetType.FullName.Equals((GetType(ItemPalette).FullName & "+Palette"), StringComparison.Ordinal)) Then
                        activated = flag
                    End If
                End If
                graphics.FillRectangle(WorkflowTheme.CurrentTheme.AmbientTheme.BackgroundBrush, bounds)
                [Using] brush As Brush = New SolidBrush(Color.FromArgb(50, WorkflowTheme.CurrentTheme.AmbientTheme.SelectionForeColor))
                    graphics.FillRectangle(brush, bounds)
                End [Using]
                graphics.DrawRectangle(SystemPens.ControlDarkDark, bounds)
                Dim image As Image = designer.Image
                image = If((designer.Image Is Nothing), SmartTag.defaultImage, image)
                Dim glyphSize As Size = WorkflowTheme.CurrentTheme.AmbientTheme.GlyphSize
                Dim size As Size = designer.SmartTagRectangle.Size
                Dim margin As Size = WorkflowTheme.CurrentTheme.AmbientTheme.Margin
                Dim destination As Rectangle = bounds
                destination.X = (destination.X + (margin.Width / 2))
                destination.Y = (destination.Y + (margin.Height / 2))
                destination.Size = size
                ActivityDesignerPaint.DrawImage(graphics, image, destination, DesignerContentAlignment.Center)
                Dim rectangle3 As Rectangle = bounds
                rectangle3.X = (rectangle3.X + (size.Width + ((3 * margin.Width) / 2)))
                rectangle3.Y = (rectangle3.Y + (margin.Height / 2))
                rectangle3.Width = (glyphSize.Width / 2)
                rectangle3.Height = (rectangle3.Height - (glyphSize.Height / 4))
                [Using] path As GraphicsPath = ActivityDesignerPaint.GetScrollIndicatorPath(rectangle3, ScrollButton.Down)
                    graphics.FillPath(Brushes.Black, path)
                    graphics.DrawPath(Pens.Black, path)
                End [Using]
            End Sub


            ' Properties
            Friend ReadOnly Property ActiveDesigner As ActivityDesigner
                Get
                    Return Me.activeDesigner
                End Get
            End Property

            Public Overrides ReadOnly Property CanBeActivated As Boolean
                Get
                    Return True
                End Get
            End Property


            ' Fields
            Private activeDesigner As ActivityDesigner
            Friend Const DefaultHeight As Integer = 2
            Private Shared defaultImage As Image = DR.GetImage("SmartTag")
        End Class
    End Class
End Namespace

